package cn.tsmchina.one.pojo;

import java.util.Date;
import java.util.List;

import org.springframework.util.StringUtils;

import cn.tsmchina.one.domain.activity.Activity;
import cn.tsmchina.one.util.C;
import cn.tsmchina.one.util.JsonUtil;


public class ActivityPojo 
{
	private int id;
	
	private String activityName; //活动名称
	
	private Date createDate; //创建时间
	
	private String activityContent;//活动内容
	
	private String images;//活动封面图片
	
	private Date startDate; //开始时间
	
	private Date endDate;//结束时间
	
	private List<Integer> joinUserId;//参加者;
	
	private boolean delFlag;//是否删除
	
	private List<Integer> praiseUserId;//赞
	
	private int activityState;//活动状态
	
	private String address;//活动地址
	
	private String phone;//联系电话
	
	private String summary;//摘要

	@SuppressWarnings("unchecked")
	public ActivityPojo(Activity activity)
	{
		this.id = activity.getId();
		this.activityName = activity.getActivityName();
		this.createDate = activity.getCreateDate();
		this.activityContent = activity.getActivityContent();
		this.images = activity.getImages();
		this.delFlag =  activity.isDelflag();
		this.summary = activity.getSummary();
		this.address = activity.getAddress();
		this.phone = activity.getPhone();
		String join = activity.getJoinUserId();
		String praise = activity.getPraiseUserId();
		if(!StringUtils.isEmpty(join))
			this.joinUserId = JsonUtil.parseObject(List.class, join);
		if(!StringUtils.isEmpty(praise))
			this.praiseUserId = JsonUtil.parseObject(List.class,praise);
	}
	
	public ActivityPojo()
	{

	}

	public int getId()
	{
		return id;
	}

	public void setId(int id)
	{
		this.id = id;
	}

	public String getActivityName()
	{
		return activityName;
	}

	public void setActivityName(String activityName)
	{
		this.activityName = activityName;
	}

	public Date getCreateDate()
	{
		return createDate;
	}

	public void setCreateDate(Date createDate)
	{
		this.createDate = createDate;
	}

	public String getActivityContent()
	{
		return activityContent;
	}

	public void setActivityContent(String activityContent)
	{
		this.activityContent = activityContent;
	}

	public String getImages()
	{
		return images;
	}

	public void setImages(String images)
	{
		this.images = images;
	}

	public Date getStartDate()
	{
		return startDate;
	}

	public void setStartDate(Date startDate)
	{
		this.startDate = startDate;
	}

	public Date getEndDate()
	{
		return endDate;
	}

	public void setEndDate(Date endDate)
	{
		this.endDate = endDate;
	}
	
	public boolean isDelFlag()
	{
		return delFlag;
	}

	public void setDelFlag(boolean delFlag)
	{
		this.delFlag = delFlag;
	}

	public int getActivityState()
	{
		Date now = new Date();
		if(this.delFlag)
			this.activityState = C.ActivityState.CANCEL;
		else if(now.getTime() < this.startDate.getTime())
			this.activityState = C.ActivityState.NO_START;
		else if(now.getTime() < this.endDate.getTime())
			this.activityState = C.ActivityState.STRTING;
		else
			this.activityState = C.ActivityState.END;
		return this.activityState;
	}

	public void setActivityState(int activityState)
	{
		this.activityState = activityState;
	}

	public List<Integer> getJoinUserId()
	{
		return joinUserId;
	}

	public void setJoinUserId(List<Integer> joinUserId)
	{
		this.joinUserId = joinUserId;
	}

	public List<Integer> getPraiseUserId()
	{
		return praiseUserId;
	}

	public void setPraiseUserId(List<Integer> praiseUserId)
	{
		this.praiseUserId = praiseUserId;
	}

	public String getAddress() {
		return address;
	}

	public void setAddress(String address) {
		this.address = address;
	}

	public String getPhone() {
		return phone;
	}

	public void setPhone(String phone) {
		this.phone = phone;
	}

	public String getSummary() {
		return summary;
	}

	public void setSummary(String summary) {
		this.summary = summary;
	}
	
	
}
